use lz4_flex::{compress_prepend_size, decompress_size_prepended};
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn compress(input: &[u8]) -> Vec<u8> {
    compress_prepend_size(input)
}

#[wasm_bindgen]
pub fn decompress(input: &[u8]) -> Result<Vec<u8>, JsValue> {
    decompress_size_prepended(input)
        .map_err(|e| JsValue::from_str(&format!("Decompression error: {:?}", e)))
}